package com.accp.conf;

import javax.servlet.http.HttpSession;

import org.springframework.ui.Model;

public class MyPage {
	public static void forPage(Model model,Integer curPage,Integer pageSize,Long ipTotalPage) {
		
		int totalPage = ipTotalPage%pageSize==0?ipTotalPage.intValue()/pageSize:ipTotalPage.intValue()/pageSize+1;
		int i=0;
		int j=0;	
				
	
		
		if(curPage-1<=1){
			i=1;
			j=totalPage>=5?5:totalPage;					
		}
		else if(curPage-2>=1&&curPage+2<=totalPage){					
			i=curPage-2;
			j=curPage+2;												
		}
		else if(curPage+2>=totalPage){
			i=totalPage-4<=0?1:totalPage-4;
			j=totalPage;																								
		}
		model.addAttribute("totalPage",totalPage );//总页码
		model.addAttribute("curPage",curPage ); //当前页码		
		
		model.addAttribute("i",i );  //循环开始的条件变量
		model.addAttribute("j",j );  //循环结束的条件变量		
	}
}
